package logic

import (
	"context"
	"wechat/models/mysql"

	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CircleListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCircleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CircleListLogic {
	return &CircleListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CircleListLogic) CircleList(in *wechatrpc.CircleListRequest) (*wechatrpc.CircleListResponse, error) {
	// todo: add your logic here and delete this line
	var list []mysql.Circle
	mysql.DB.Find(&list)
	var cir []*wechatrpc.Circle
	for _, cc := range list {
		lis := wechatrpc.Circle{
			Context: cc.Context,
			UserId:  int64(cc.UserId),
		}
		cir = append(cir, &lis)
	}
	return &wechatrpc.CircleListResponse{
		List: cir,
	}, nil
}
